package com.yyjj.hangqing.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.aries.ui.view.title.TitleBarView;
import com.yyjj.hangqing.R;
import com.yyjj.hangqing.adapter.viewpager.VPTitleAdapter;
import com.zhengsr.viewpagerlib.indicator.TabIndicator;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import tech.com.commoncore.base.BaseTitleFragment;
import tech.com.commoncore.utils.OnNoDoubleClickListener;


public class HQFragment extends BaseTitleFragment{
    private com.zhengsr.viewpagerlib.indicator.TabIndicator mLineIndicator;
    private ViewPager mViewpager;
//    默认是all全部，股票是gp，混合是hh，债券zq，指数zs，保本bb，QDII是qdii，LOF是lof。FOF是fof
    List<Fragment> fragmentList = new ArrayList<>();

    public static HQFragment newInstance(Bundle args) {
        HQFragment fragment = new HQFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void setTitleBar(TitleBarView titleBar) {
        titleBar.setLeftText(getResources().getString(R.string.hq_hq_app_name)).setLeftTextSize(25).setTitleMainTextColor(Color.WHITE).setStatusBarLightMode(true)
                .setTextColor(getResources().getColor(R.color.text_title))
                .setBackground(getResources().getDrawable(R.color.colorWhite));
    }

    @Override
    public int getContentLayout() {
        return R.layout.hq_fragment;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        //getResources().getString(R.string.hq_hq_all),
        String[] TYPES = {
                getResources().getString(R.string.hq_hq_gp),
                getResources().getString(R.string.hq_hq_hh),
                getResources().getString(R.string.hq_hq_cq),
                getResources().getString(R.string.hq_hq_bb)};
        mLineIndicator = (TabIndicator) mContentView.findViewById(R.id.line_indicator);
        mViewpager = (ViewPager) mContentView.findViewById(R.id.viewpager);

        mLineIndicator.setViewPagerSwitchSpeed(mViewpager,600);
        mLineIndicator.setTabData(mViewpager, Arrays.asList(TYPES), new TabIndicator.TabClickListener() {
            @Override
            public void onClick(int position) {
                //顶部点击的方法公布出来
                mViewpager.setCurrentItem(position);
            }
        });

//        fragmentList.add(CoinListFragment.newInstance("all"));
        fragmentList.add(CoinListFragment.newInstance("gp"));
        fragmentList.add(CoinListFragment.newInstance("hh"));
        fragmentList.add(CoinListFragment.newInstance("zq"));
        fragmentList.add(CoinListFragment.newInstance("bb"));
        mViewpager.setOffscreenPageLimit(4);
        mViewpager.setAdapter(new VPTitleAdapter(getChildFragmentManager(),fragmentList,Arrays.asList(TYPES)));

    }
}
